import random

def guess_number_game():
    number_to_guess = random.randint(0, 10000)
    attempts = 0

    print("欢迎来到猜数字游戏！")
    print("我已经想好了一个0到10000之间的数字。")

    while True:
        try:
            user_guess = int(input("请输入你猜的数字："))
            attempts += 1

            if user_guess < 0 or user_guess > 10000:
                print("请输入一个0到10000之间的数字。")
            elif user_guess < number_to_guess:
                print("太低了！再试一次。")
            elif user_guess > number_to_guess:
                print("太高了！再试一次。")
            else:
                print(f"恭喜你，猜对了！你一共猜了{attempts}次。")
                break
        except ValueError:
            print("请输入一个有效的整数。")

if __name__ == "__main__":
    guess_number_game()
